@use '@/styles/variables' as *;  // 导入全局变量
@use '@/styles/mixins' as *;     // 导入全局 mixins

$z-index-sticky: 1000;  // 如果变量不存在于全局变量中，在这里定义

// 如果 mixins 文件不存在，直接在这里定义 mixin
@mixin flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

// 头部容器样式
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: $z-index-sticky;
  background-color: $primary-color;
  width: 100%;
}

// 导航带样式
.nav-belt {
  display: flex;
  height: $header-height;
  padding: 0;
  position: relative;
  color: $text-white;

  > div {
    display: flex;
    align-items: center;
  }
}

// 左侧导航区域
.nav-left {
  min-width: $nav-left-width;
  padding-left: $spacing-sm;
  display: flex;
  align-items: center;
  gap: 8px;
}

// 中间填充区域
.nav-fill {
  flex: 1;
  min-width: 0;
  padding: 0 16px;

  @media screen and (min-width: $breakpoint-md) {
    padding: 0 $spacing-lg;
  }
}

// 右侧导航区域
.nav-right {
  min-width: $nav-right-width;
  padding-right: $spacing-lg;
  justify-content: flex-end;
  display: flex;
  align-items: center;
  gap: 3px;
}

.nav-search {
  display: flex;
  width: 100%;
  height: $search-height;
  margin: 0 auto;
  border-radius: $spacing-sm;
  overflow: hidden;
  background-color: $text-white;

  &:focus-within {
    outline: none;
    box-shadow: 0 0 0 2px $hover-color;
  }

  &-select {
    position: relative;
    width: auto;
    min-width: 52px;
    border-right: 1px solid $border-color;

    select {
      width: 100%;
      height: $search-height;
      padding: 0 28px 0 10px;
      border: none;
      background-color: $bg-light;
      color: $text-primary;
      cursor: pointer;
      appearance: none;
      white-space: nowrap;
      outline: none;

      &:focus {
        outline: none;
        box-shadow: none;
      }
    }

    &::after {
      content: '';
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%);
      width: 0;
      height: 0;
      border-left: 4px solid transparent;
      border-right: 4px solid transparent;
      border-top: 4px solid $icon-color;
      pointer-events: none;
    }
  }

  &-input {
    flex: 1;
    height: $search-height;
    padding: 0 10px;
    border: none;
    color: $text-primary;
    outline: none;

    &:focus {
      box-shadow: none;
    }
  }

  &-submit {
    width: 45px;
    height: $search-height;
    border: none;
    background-color: $hover-color;
    cursor: pointer;

    &:hover {
      background-color: $secondary-color;
    }

    .fa-search {
      color: $text-primary;
      font-size: $font-size-lg;
    }
  }
}

// 主导航栏样式
.nav-main-wrapper {
  position: relative;
  background-color: $primary-light;
  transition: all 0.3s ease-in-out;
  max-height: $nav-height;
}

// 隐藏导航栏样式
.nav-main-hidden {
  max-height: 0;
  opacity: 0;
  visibility: hidden;
}

// 主导航栏样式
.nav-main {
  display: flex;
  align-items: center;
  height: $nav-height;
  padding: 0 $spacing-lg;
  color: $text-white;
}

.nav-sprite {
  background-image: url(@/assets/images/nav-sprite-global-1x-reorg-privacy._CB541706272_.png);
  background-repeat: no-repeat;
  display: inline-block;
}

.nav-logo-link {
  display: flex;
  align-items: center;
  padding: 1px 8px 0 8px;
  border: 1px solid transparent;
  text-decoration: none;
  height: 50px;
  margin-right: 4px;

  &:hover {
    border-color: $text-white;
  }
}

.amazon-logo {
  width: 97px;
  height: 30px;
  object-fit: contain;
}

.location {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;

  .fa-map-marker-alt {
    font-size: $font-size-lg;
    color: $text-white;
    margin-right: 2px;
  }

  .location-text {
    display: flex;
    align-items: center;
    white-space: nowrap;
  }
}

.flag-icon {
  width: 18px;
  height: 13px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.nav-item {
  cursor: pointer;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: $border-radius-sm;
  color: $text-white;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cart-link {
  @include flex-center;
  position: relative;
  padding: 2px 8px;
  text-decoration: none;
  border: 1px solid transparent;
  color: $text-white;
  gap: 4px;
  cursor: pointer;

  &:hover {
    border-color: $text-white;
  }

  .nav-cart-wrapper {
    position: relative;
    margin: 0 2px;
  }

  .nav-cart-count {
    position: absolute;
    top: -4px;
    left: 13px;
    min-width: 20px;
    height: 20px;
    color: $secondary-color;
    font-size: 16px;
    text-align: center;
    line-height: 20px;
    font-weight: bold;
    z-index: 1;
  }

  .nav-cart-icon {
    width: 38px;
    height: 26px;
    background-position: -10px -340px;
  }
}

// 全部分类按钮样式
.nav-all {
  @include flex-center;
  gap: $spacing-xs;
  height: 100%;
  padding: 0 $spacing-md;
  border: none;
  background: none;
  color: $text-white;
  cursor: pointer;
  font-weight: bold;
  border: 1px solid transparent;
  min-width: $nav-height * 1.5;

  &:hover {
    border-color: $text-white;
  }

  i {
    font-size: $font-size-lg;
  }
}

// 导航列表样式
.nav-list {
  @include flex-start;
  height: 100%;
  list-style: none;
  margin: 0;
  padding: 0 0 0 $spacing-md;
  overflow-x: auto;  // 添加横向滚动
  scrollbar-width: none;  // 隐藏滚动条 (Firefox)
  -ms-overflow-style: none;  // 隐藏滚动条 (IE/Edge)

  &::-webkit-scrollbar {
    display: none;  // 隐藏滚动条 (Chrome/Safari)
  }

  li {
    height: 100%;
    flex-shrink: 0;  // 防止项目被压缩
  }

  a {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 $spacing-md;
    color: $text-white;
    text-decoration: none;
    border: 1px solid transparent;
    font-size: $font-size-sm;
    white-space: nowrap;

    &:hover {
      border-color: $text-white;
    }
  }
  .active-link {
    border-color: $text-white;
  }
}

.nav-line-1-2 {
  line-height: 14px;

  .text-xs {
    font-size: 11px;
  }

  .text-sm {
    font-size: 13px;
  }

  .text-md {
    font-size: 14px;
  }

  &.font-bold {
    font-size: 14px;
  }
}

.nav-global-location {
  margin-left: auto;
  padding-right: 8px;
}

// 响应式设计
@include respond-to('lg') {
  .nav-fill {
    padding: 0 $spacing-md;
  }
}

@include respond-to('md') {
  .nav-item:not(.cart-link) {
    display: none;
  }

  .nav-fill {
    padding: 0 $spacing-sm;
  }
}

@include respond-to('sm') {
  .subnav {
    display: none;
  }
}

.language-selector {
  margin: 0 $spacing-md;

  .language-display {
    display: flex;
    align-items: center;
    //justify-content: space-between;
    cursor: pointer;
    color: $text-white;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 2px;
    min-width: 100px;
    //width: 100px;

    &:hover {
      border-color: $text-white;
    }

    .flag-icon {
      flex-shrink: 0;
    }

    .lang-text {
      margin: 0 4px;
      font-size: 13px;
      font-weight: 500;
      //width: 24px;
      text-align: center;
      flex-shrink: 0;
    }

    .fa-caret-down {
      font-size: 12px;
      flex-shrink: 0;
    }
  }
}

:deep(.el-dropdown-menu) {
  min-width: 220px;
  padding: 4px 0;

  .el-dropdown-menu__item {
    padding: 8px 12px;

    .lang-item {
      display: flex;
      align-items: center;
      width: 100%;

      .far {
        color: $hover-color;
        font-size: 14px;
        width: 16px;
        margin-right: 8px;
        text-align: center;
      }

      .flag-icon {
        margin-right: 8px;
      }

      span {
        flex: 1;
      }
    }
  }
}

.hover-effect {
  &:hover {
    border-color: $text-white;
  }
}
